//
//  UserInfoTableViewCell.m
//  A_Project_DLS151129_SQ
//
//  Created by 151129-49宋强 on 16/1/25.
//  Copyright © 2016年 www.lanou3g.com蓝鸥. All rights reserved.
//

#import "UserInfoTableViewCell.h"

@implementation UserInfoTableViewCell

- (void)dealloc
{
    [_timeLabel release];
    [_contentLabel release];
    [_styleLabel release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.timeLabel = [[UILabel alloc] init];
      //  _timeLabel.backgroundColor = [UIColor redColor];
        _timeLabel.font = [UIFont boldSystemFontOfSize:15];
        [self.contentView addSubview:_timeLabel];
        [_timeLabel release];
        self.contentLabel = [[UILabel alloc] init];
      //  _contentLabel.backgroundColor = [UIColor redColor];
        _contentLabel.numberOfLines = 0;
        [self.contentView addSubview:_contentLabel];
        [_contentLabel release];
        self.styleLabel = [[UILabel alloc] init];
        _styleLabel.font = [UIFont systemFontOfSize:12];
        _styleLabel.text = @"发布了一个碎片";
        [self.contentView addSubview:_styleLabel];
        [_styleLabel release];
    }
    return self;
}
+ (CGFloat)heightWithText:(NSString *)text
{
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:17]};
    CGSize s = CGSizeMake(355, 1000);
    CGRect r = [text boundingRectWithSize:s options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return r.size.height;
    
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _timeLabel.frame = CGRectMake(10, 10, 150, 20);
    _styleLabel.frame = CGRectMake(self.frame.size.width - 10 - 120, 10, 120, 20);
    CGFloat h = [[self class] heightWithText:_contentLabel.text];
    _contentLabel.frame = CGRectMake(10, 10 + _timeLabel.frame.size.height + 20, self.frame.size.width - 20, h);
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
